//
//  MQChangeSkin.m
//  MQ
//
//  Created by 曾杰 on 15/11/12.
//  Copyright © 2015年 徐永祥. All rights reserved.
//

#import "MQChangeSkin.h"

@implementation MQChangeSkin

- (id)initWithFrame:(CGRect)frame
{
    NSArray *arr = @[@"纯色白",@"木板黄",@"菱形绿",@"羊皮纸",@"海洋蓝",@"书柜黄",@"可爱黄"];
    self = [super initWithFrame:frame];
    if (self) {
        for (int i = 0; i < arr.count; i++) {
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
            button.frame = CGRectMake(0,30*i+5 , self.bounds.size.width, 30);
            [button setTitle:arr[i] forState:(UIControlStateNormal)];
            [button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
            button.tag = 20+i;
            [button addTarget:self action:@selector(changeSkin:) forControlEvents:(UIControlEventTouchUpInside)];
            [self addSubview:button];
        }
        self.backgroundColor = [UIColor whiteColor];
    
    }
    return self;
}
+ (instancetype)defaultPopupView{
    return [[MQChangeSkin alloc]initWithFrame:CGRectMake(0, 0, 195, 210)];
}
- (void)changeSkin:(UIButton *)button
{
    UIImageView *ImageView = _parentVC.view.subviews[0];
    if (button.tag == 20) {
        _picStr = @"";
    }
    if (button.tag == 21) {
        _picStr = @"texture_8.jpg";
    }
    if (button.tag == 22) {
        _picStr = @"texture_9.jpg";

    }if (button.tag == 23) {
        _picStr = @"texture_11.jpg";

    }if (button.tag == 24) {
        _picStr = @"texture_16.jpg";

    }
    if (button.tag == 25) {
        _picStr = @"texture_7.jpg";

    }
    if (button.tag == 26) {
        _picStr = @"texture_24.jpg";
    }
    [ImageView setImage:[UIImage imageNamed:_picStr]];
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    [user setObject:_picStr forKey:@"picStr"];
    
}


@end
